﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using control.Biz;

public partial class usercontrol_user : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["account"] != null && Request.QueryString["cm"]!=null)
            {
                if (Request.QueryString["cm"] == "edit")
                {
                    mtv1.ActiveViewIndex = 0;
                    BizKhachHang _user = (BizKhachHang)Session["account"];
                    lbID.Text = _user.IDKhachHang.ToString();
                    lbMa.Text = _user.MaKhachHang;
                    txtHoTen.Text = _user.TenKH;
                    txtDiaChi.Text = _user.Diachi;
                    txtEmail.Text = _user.Email;
                    txtSoDT.Text = _user.SDT.ToString();
                    lbcommand.Text = "Thông Tin Cá Nhân";
                }
                else
                    mtv1.ActiveViewIndex = 1;
            }
            else
                Response.Redirect("Default.aspx");
        }
    }

    
    protected void Button2_Click(object sender, EventArgs e)
    {
        BizKhachHang _user = (BizKhachHang)Session["account"];
        if (TextBox8.Text == _user.Matkhau)
        {
            _user.Matkhau = TextBox9.Text;
            _user.changeInfo();
            Label5.Text = "Đổi mật khẩu thành công";
        }
        else
        {
            Label5.Text = "Mật khẩu cũ không đúng !!!";
        }
    }
    protected void btdongy_Click(object sender, EventArgs e)
    {

        BizKhachHang user = (BizKhachHang)Session["account"];
            user.TenKH = txtHoTen.Text;
            user.Diachi = txtDiaChi.Text;
            user.Email = txtEmail.Text;
            user.SDT = 0;
            try { user.SDT = Convert.ToInt32(txtSoDT.Text); }
            catch { }
            bool resuilt=user.changeInfo();
            if (resuilt == true)
                Label6.Text = "Thành công";
 

    }
    
}
